home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
60914
/
60914.xpi
/
chrome
/
content
/
save.js
< prev
next >
Wrap
Text File
|
2010-01-20
|
3KB
|
105 lines
var PersonasRotatorBackSave = {
getlibraryfileURI : function () {
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("ProfD", Components.interfaces.nsIFile);
file.append("personasrotator");
file.append("library.rdf");
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var URL = ios.newFileURI(file);
return URL.spec;
},
populateItems : function () {
var ds=PersonasRotatorRDF.rdfService.GetDataSourceBlocking(PersonasRotatorBackSave.getlibraryfileURI());
var container=PersonasRotatorRDF.rdfContainerUtils.MakeSeq(ds,PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator:library"));
var genericpersonasseqenumurator=container.GetElements();
var namePredicate = PersonasRotatorRDF.rdfService.GetResource("urn:personasrotator#name");
while (genericpersonasseqenumurator.hasMoreElements()) {
var collection=genericpersonasseqenumurator.getNext();
var nametarget=ds.GetTarget(collection,namePredicate,true);
if (nametarget) {
var name = nametarget.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
}
var newmenuitem=document.createElement("menuitem");
newmenuitem.setAttribute("label",name);
newmenuitem.setAttribute("id",name+"menuitem");
newmenuitem.setAttribute("class","collection-menuitem");
document.getElementById("collistpopup").appendChild(newmenuitem);
}
},
cancelDialog : function () {
return true;
},
acceptDialog : function () {
if(document.getElementById("collist").selectedIndex==-1) {alert("Please choose a collection to save your persona in");return false;}
var doc=window.arguments[0];
var chosencolname=document.getElementById("collist").selectedItem.getAttribute("label");
window.opener.PersonasRotator.savepreview(chosencolname,window.opener.PersonasRotator.retrievetabpersonaimagefrompersonasrotator(doc),doc);
return true;
},
handleWindowLoad :function(event){
PersonasRotatorBackSave.populateItems();
document.getElementById("savepersonabutton").addEventListener("command",PersonasRotatorBackSave.handleSaveBackButtonCommand,false);
document.getElementById("cancelsavepersonabutton").addEventListener("command",PersonasRotatorBackSave.cancelSaveBackButtonCommand,false);
},
handleSaveBackButtonCommand:function(event){
if(PersonasRotatorBackSave.acceptDialog()) window.close();
},
cancelSaveBackButtonCommand:function(event){
window.close();
}
}
window.addEventListener("load",PersonasRotatorBackSave.handleWindowLoad,false);